package cn.ryh.gat1400.controller;

import cn.ryh.gat1400.model.KeepaliveObject;
import cn.ryh.gat1400.model.RegisterObject;
import cn.ryh.gat1400.model.ResponseStatusObject;
import cn.ryh.gat1400.model.UnRegisterObject;
import cn.ryh.gat1400.service.RegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: aiLin
 * @Date: 2020/9/25 16:48
 * @desc: 注册中心
 */
@RestController
@Slf4j
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    /**
     * 注册接口
     * @param registerObject
     * @return
     */
    @PostMapping("/VIID/System/Register")
    public ResponseStatusObject register(@RequestBody RegisterObject registerObject){
        log.info("/VIID/System/Register:"+registerObject.toString());
        return registerService.register(registerObject);
    }

    /**
     * 注销接口
     * @param unRegisterObject
     * @return
     */
    @PostMapping("/VIID/System/UnRegister")
    public ResponseStatusObject unRegister(@RequestBody UnRegisterObject unRegisterObject){
        return registerService.unRegister(unRegisterObject);
    }

    /**
     * 心跳接口
     * @param keepaliveObject
     * @return
     */
    @PostMapping("/VIID/System/Keepalive")
    public ResponseStatusObject keepalive(@RequestBody KeepaliveObject keepaliveObject){
        log.info("/VIID/System/Keepalive:"+keepaliveObject.toString());
        return registerService.keepalive(keepaliveObject);
    }
}
